/*
 * Niiuzu
 * Copyright (C) 2011  Thierry Nowak
 * 
 * This program is free software: you can redistribute it and/or modify it under
 * the terms of the GNU General Public License as published by the Free Software
 * Foundation, either version 3 of the License, or (at your option) any later
 * version.
 * 
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 * details.
 * 
 * You should have received a copy of the GNU General Public License along with
 * this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package com.niiuzu.client.screen.authentification.signup;

import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.HasClickHandlers;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.Anchor;
import com.google.gwt.user.client.ui.HasValue;
import com.google.gwt.user.client.ui.PushButton;
import com.google.gwt.user.client.ui.TextBox;
import com.google.gwt.user.client.ui.Widget;
import com.niiuzu.client.util.view.AbstractPopupView;

/**
 * Implémentation de la vue de la création de compte.
 */
public class SignUpViewImpl extends AbstractPopupView implements SignUpView {

	/**
	 * Interface {@link UiBinder} adaptée à la vue {@link SignUpViewImpl}.
	 */
	interface SuitedUiBinder extends UiBinder<Widget, SignUpViewImpl> {

	}

	@UiField
	TextBox mailField;
	@UiField
	TextBox passwordField;
	@UiField
	TextBox passwordConfirmField;
	@UiField
	PushButton closeButton;
	@UiField
	Anchor cancelAnchor;
	@UiField
	PushButton validateButton;

	@Override
	public void createView() {
		SuitedUiBinder uiBinder = GWT.create(SuitedUiBinder.class);
		initWidget(uiBinder.createAndBindUi(this));
	}

	@Override
	public HasClickHandlers getCloseButtonHasClickHandlers() {
		return closeButton;
	}

	@Override
	public void focusMailField() {
		mailField.setFocus(true);
	}

	@Override
	public HasClickHandlers getCancelHasClickHandlers() {
		return cancelAnchor;
	}

	@Override
	public HasValue<String> getMailHasValue() {
		return mailField;
	}

	@Override
	public HasValue<String> getPasswordConfirmationHasValue() {
		return passwordConfirmField;
	}

	@Override
	public HasValue<String> getPasswordHasValue() {
		return passwordField;
	}

	@Override
	public HasClickHandlers getValidationHasClickHandlers() {
		return validateButton;
	}
}
